package com.qilin.hammer;

import java.io.ByteArrayOutputStream;
import java.io.PrintStream;
import java.io.StringWriter;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerConfigurationException;
import javax.xml.transform.TransformerException;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.dom.DOMSource;
import javax.xml.transform.stream.StreamResult;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.log4j.Logger;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;


public class Test {
	public int x=0;
	public int y=0;
	private static DocumentBuilderFactory domFactory=DocumentBuilderFactory.newInstance();
	protected DocumentBuilder domBuilder = null;

	public Test(){
		x=y=0;
	}
	protected static String getStringResult(Node node) {
        TransformerFactory transFactory=TransformerFactory.newInstance();
        try {
            Transformer transformer = transFactory.newTransformer();
            transformer.setOutputProperty("encoding", "utf-8");
            transformer.setOutputProperty("indent", "yes");

            DOMSource source=new DOMSource();
            source.setNode(node);
            StringWriter sw = new StringWriter();
            StreamResult result=new StreamResult(sw);
            //result.setOutputStream(System.out);
            transformer.transform(source, result);
            return sw.toString();
        } catch (TransformerConfigurationException e) {
            e.printStackTrace();
        } catch (TransformerException e) {
            e.printStackTrace();
        }
        return "";
	}
	public void _10to2(int x){
		if(x>1)
			_10to2(x/2);
		System.out.print(x%2);	
	}
	
	public static void main(String[] args){
		Test t = new Test();
		DocumentBuilder domBuilder = null;
		try {
			 domBuilder = domFactory.newDocumentBuilder();
			//access_token = SinaAuthService.getAccessToken();
		} catch (ParserConfigurationException e) {
			e.printStackTrace();
		}
		Document doc = domBuilder.newDocument();
		Element root = doc.createElement("root");
		doc.appendChild(root);

		System.out.println(getStringResult(root));
		String 中文 = new String("hello");
		System.out.println(中文);
		
		String a = "1"; 
		a =	(String)null;
		System.out.println(a);
	}
}
